<template>
  <div class="weui-tab">
    <div class="weui-navbar">
      <div class="weui-navbar__item" v-for="(item, _index) in list" :class="{'weui-bar__item_on':_index==index}"
           @click="onClick(_index)">
        {{item}}
      </div>
    </div>
    <div class="weui-tab__panel">
      <slot>
      </slot>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      list: {
        type: Array,
        default() {
          return ['tab0', 'tab1']
        }
      },
      index: {
        type: Number,
        default: 0
      }
    },
    methods: {
      onClick(index) {
        this.$emit('on-click', index)
      }
    }
  }
</script>

<style>
  @import 'weui/dist/style/weui.min.css';
</style>
